import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useTabStore = defineStore('tab', () => {
  const currentTab = ref('all')
  const currentPageName = ref('Home') // 默认是home页面
  const searchKeyword = ref('')
  const category = ref('')
  function setTab(tab) {
    currentTab.value = tab
  }
  function setPageName(pageName) {
    currentPageName.value = pageName
  }

  function setSearchKeyword(keyword) {
    searchKeyword.value = keyword
  }
  function setCategory(cat) {
    category.value = cat
  }

  function init_data() {
    currentTab.value = 'all'
    currentPageName.value = 'Home'
    searchKeyword.value = ''
    category.value = ''
  }
  return { currentTab, setTab, currentPageName, setPageName, searchKeyword, setSearchKeyword, category, setCategory, init_data }
})